Skip to content

feat(router): serial vLLM Mooncake legs (INFERA_VLLM_MOONCAKE_SERIAL=1) - #246

Closed
llying-001 wants to merge 1 commit into
mainfrom
llying/vllm-mooncake-serial
Closed

llying-001 wants to merge 1 commit into
mainfrom
llying/vllm-mooncake-serial

Conversation

@llying-001

Copy link
Copy Markdown
Contributor

Description

With vLLM's MooncakeConnector the router posts the prefill and decode legs of a PD request concurrently. The decode
reserves KV for a request as soon as its leg arrives, while a prefill that reorders its queue (cache-aware admission,
priority) can hold finished KV that the decode has not reserved yet. Under memory pressure each side then waits on the
other and the deployment stalls: on a GLM-5.2 PD deployment (8x MI355X, prefill PP4 with cache-aware admission, decode
DP4) the prefill sat at 0 running / 76 waiting / 99.7% KV with zero prompt throughput, and client responses stopped
for over a minute.

INFERA_VLLM_MOONCAKE_SERIAL=1 posts the decode leg only after the prefill has answered, in both routers. The Python
router already had a serial-pull dispatcher; the Rust router only had a serial path for ATOM.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Changes

  • Python: VllmMooncakeProtocol.topology becomes serial-pull when the variable is set (the existing serial
    dispatcher; the decode needs no handoff from the prefill reply, the transfer room is in both bodies).
  • Rust: vllm_serial_pull posts the prefill, waits for its reply, then runs the decode leg through serial_decode,
    shared with ATOM's serial pull; a failed prefill is returned to the client and never reaches the decode.
  • Default (unset) behavior is unchanged: concurrent legs.

Validation

  • Python unit tests (pytest -m "not slow and not integration", Python 3.10): 3,055 passed (main 3,054), no new
    failures. New: the protocol switches topology and pairs the transfer ids.
  • Rust (cargo fmt --check, cargo clippy --locked --all-targets -- -D warnings, cargo test --locked): clean, 370
    passed (main 369). New: disagg::tests::vllm_serial_pull_posts_the_decode_after_the_prefill_reply checks the decode
    is not posted while the prefill is running, and is never posted after a failed prefill.
  • pre-commit run --files <changed files> passes.
  • End to end: every GLM-5.2 PD run since we enabled it (cache-aware admission on the prefill, Rust router with this
    path, AgentX C104) completed without a stall, e.g. 48,572 tok/s/GPU over 3600 s (single runs).

Notes: the switch is an environment variable, like the Python router's existing one; happy to turn it into a router CLI
flag instead. AI assistance was used to write this change and description.

Checklist:

  • The functionality is complete
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

With vLLM's MooncakeConnector the router posts the prefill and decode legs
concurrently. The decode reserves KV for a request as soon as its leg
arrives, while a prefill that reorders its queue (cache-aware admission,
priority) can hold finished KV the decode has not reserved yet; under
memory pressure each side then waits on the other and the deployment
stalls.

INFERA_VLLM_MOONCAKE_SERIAL=1 posts the decode only after the prefill has
answered, in both routers:

- Python: VllmMooncakeProtocol.topology becomes serial-pull (the existing
  serial dispatcher; the decode needs no handoff from the prefill reply,
  the room is in both bodies).
- Rust: vllm_serial_pull posts the prefill, waits for its reply and then
  runs the decode leg through serial_decode, shared with ATOM's
  serial_pull; a failed prefill is returned to the client and never
  reaches the decode.

Tests: the Python protocol switches topology and pairs the transfer ids;
the Rust test checks the decode is not posted while the prefill is still
running, and is never posted after a failed prefill.

Signed-off-by: liyingli <liyingli@amd.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
llying-001 added a commit that referenced this pull request Nov 19, 2026
…y repo at the user's request: AMD-AGI/Infera #246 (U16) #247 (U24) #248 (U14) #249 (U15) #250 (U28) #251 (U7), branches llying/<topic>, conventional titles; fork PRs llying-001/Infera #1-#6 closed and pointed at them

Signed-off-by: liyingli <liyingli@amd.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@llying-001
llying-001 marked this pull request as ready for review November 23, 2026 14:21
Copilot AI balanced review requested due to automatic review settings November 23, 2026 14:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The serial Mooncake paths in both routers bypass NATS transport and admission checks, causing requests to fail for NATS-only workers or bypass configured backlog limits.

2 open issues
What changed in this PR

Adds opt-in serial dispatch for vLLM Mooncake prefill and decode requests in both routers to address KV-memory stalls. Concurrent dispatch remains the default.

Changes:

  • Enables Python’s existing serial dispatcher with INFERA_VLLM_MOONCAKE_SERIAL=1.
  • Adds Rust serial Mooncake dispatch, sharing decode handling with ATOM and stopping on prefill failure.
  • Adds tests for Python topology selection and transfer IDs, plus Rust request ordering and prefill-failure handling.
File Description
tests/​unit/​router/​test_vllm_mooncake_protocol.py Tests serial topology selection and matching transfer IDs.
rust/​router/​src/​disagg.rs Adds serial Mooncake dispatch, shared decode handling, and sequencing tests.
infera/​router/​disagg_protocols/​vllm_mooncake.py Selects serial topology through the environment variable and clarifies handoff behavior.

Review effort: Balanced

Comment on lines +59 to +61
topology: Literal["concurrent", "serial-pull"] = (
"serial-pull" if os.environ.get("INFERA_VLLM_MOONCAKE_SERIAL") == "1" else "concurrent"
)
Comment thread rust/router/src/disagg.rs
Comment on lines +178 to +179
if proto == protocol::PdProtocol::VllmMooncake && vllm_mooncake_serial() {
return vllm_serial_pull(state, &p, &d, path, p_body, d_body, stream, guard).await;
llying-001 added a commit that referenced this pull request Nov 23, 2026
…of the 10 PRs against vLLM main afb35f85e (239 commits past the PR base) and Infera main (unchanged): U11 duplicated by upstream draft #69348 (not submitted); U13 half covered by merged #68006, needs the reworked patch (U13-rework-on-afb35f85e.patch, not run) and re-verification; U17 / U19 not upstream, review passed, not opened on vllm-project/vllm (AGENTS.md needs the submitter's own line-by-line review), U19 coupled with open #69254; Infera #246-#251 reviewed and marked ready

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: liyingli <liyingli@amd.com>
@llying-001

Copy link
Copy Markdown
Contributor Author

Folded into #256 (GLM-5.2 vLLM P4D4 example, image and the infera changes it needs); the commit is carried there unchanged.

@llying-001 llying-001 closed this Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants